<extend name="Public/base"/>

<block name="body">

	 <link href="__CSS__/list.css" rel="stylesheet">
	 <div class="container">
	 	
	 	<!-- 面包屑 -->
	 	<div class="row">
	 	<ol class="breadcrumb">
		  <li><a href="{:U('Index/index')}">{:C('WEB_SITE_TITLE')}</a></li>
		  <li class="active"> {$cate['category_name']}   </li>
		</ol>
        </div>
	 	<include file="category" />
	 	<div class="row">
	 		<include file="recommend_goods" />
	 	</div>
	 	<div class="row">
	 		<ul class="nav nav-tabs">
		  <li role="presentation" class="<eq name="sort" value="create_time">active</eq>"><a href="{:U('Goods/cate',array('id'=>$cate['id'],'type'=>$type))}">默认</a></li>
		  <li role="presentation" class="<eq name="sort" value="volume">active</eq>"><a href="{:U('Goods/cate',array('id'=>$cate['id'],'sort'=>'volume','type'=>$type))}">销量</a></li>
		  <li role="presentation" class="<eq name="sort" value="price">active</eq>"><a href="{:U('Goods/cate',array('id'=>$cate['id'],'sort'=>'price','type'=>$type))}">价格</a></li>
		  <li role="presentation" class="<eq name="sort" value="hits">active</eq>"><a href="{:U('Goods/cate',array('id'=>$cate['id'],'sort'=>'hits','type'=>$type))}">浏览量</a></li>
		</ul>
	 	</div>
	 	<div class="row">
	 		<include file="Public:goods_list" />
	 	</div>
	 	
	 	<notempty name="_page">
    	 <div class="row">
	        	<button id="next" class="btn" p="2" total-page="{$total_page}">
					点击加载更多
				</button>
	      </div>
  	  </notempty>
      </div>	 
</block>
<block name="script">
<script>
	$(function(){
		$('.goods-list').find('li').each(function(){

			a = $('.goods-list').innerWidth()/4*1.4;
			b = $('.goods-list').innerWidth()/4*0.95;
			$(this).find('.goods-pic').each(function(){
				$(this).innerHeight(Math.round(b)-1);	
			});
			$(this).innerHeight(Math.round(a)-1);	
			
		});
		$(".goods-list li").hover(
 				function(){
 				   //当鼠标放上去的时候,程序处理
 				   $(this).addClass("hover1 hover");
 				},
 				function(){
 				   //当鼠标离开的时候,程序处理
 				   $(this).removeClass("hover1 hover");
 		});
 		highlight_subnav("{:U('Goods/cate',array('id'=>$top_category['id']))}");
 		
		$('.category-item').find('a[href="'+'{$url}'+'"]').addClass('active');
		$('#next').click(function(){
			  	LoadPage(); 
			  	$('#next').attr('disabled',true);
			  	$('#next').addClass('disabled');
		});
		
	});
	function LoadPage(){
		var currentPage = $('#next').attr('p') ? $('#next').attr('p') : 1;
		$.get("{:U('Goods/cate?id='.$cate['id'])}",{p:currentPage},function(result){
			$('#next').attr('disabled',false);
			$('#next').removeClass('disabled');
			if(result.errno==0){
				$('.goods-list ul').append(result.content);
				$('#next').attr('p',result.p);
				if(result.p>$('#next').attr('total-page')){
					$('#next').html('木有了，亲');
					$('#next').attr('disabled',true);
					$('#next').addClass('disabled');
				}
			}
			
		},'json');	
	}
	
	</script>
</block>
